home *** CD-ROM | disk | FTP | other *** search
/ 360 Degrees of: Yellowstone National Park / 360 Degrees of: Yellowstone National Park.iso / pc / data / exhibit.cst / 00057_polhemus scripts.ls < prev    next >
Encoding:
Text File  |  2008-04-21  |  2.8 KB  |  132 lines

  1. on pcalculatecoords
  2.   -- Read and calculate the Coordinates for the Polhemus Patriot wand
  3.   global vX
  4.   global vY
  5.   global vZ
  6.   global pclick
  7.   
  8.   global testvX
  9.   global testvY
  10.   global testvZ
  11.   
  12.   --pclick = 0
  13.   
  14.   
  15.   --override the polhemus if the cursor is in the tactile model display
  16.   
  17.   if the mouseH > 0 then
  18.     vX = float((float(the mouseH) - 1024.0) / 32.0)
  19.     vY = float(float(the mouseV) / 32.0)
  20.     
  21.     --pclick = 0
  22.     
  23.   else
  24.     myfile_x = new xtra("fileio")
  25.     openFile(myfile_x, "polhemus/z.txt", 0)
  26.     vXtemp = readFile(myfile_x)
  27.     
  28.     --this checks for misread files
  29.     if vXtemp > -500 then
  30.       vX = vXtemp
  31.     end if
  32.     
  33.     
  34.     --this tests the data and makes sure it is within range
  35.     if vX > 32.0 then
  36.       vX = 32.0
  37.     end if
  38.     if vX < 0.0 then
  39.       vX = 0.0
  40.     end if
  41.     
  42.     
  43.     myfile_y = new xtra("fileio")
  44.     openFile(myfile_y, "polhemus/y.txt", 0)
  45.     vYtemp = readFile(myfile_y)
  46.     
  47.     --this checks for misread files
  48.     if vYtemp > -500 then
  49.       vY = vYtemp
  50.     end if
  51.     
  52.     
  53.     --this tests the data to make sure it is within range
  54.     if vY < 0.0 then
  55.       vY = 0.0
  56.     end if
  57.     if vY > 24.0 then  
  58.       vY = 24.0
  59.     end if
  60.     
  61.     --myfile_z = new xtra("fileio")
  62.     --openFile(myfile_z, "polhemus/x.txt", 0)
  63.     --vZ = readFile(myfile_z)
  64.     --vZ = 0.0
  65.     --put vX
  66.     --put vY
  67.     
  68.     myfile_pclick = new xtra("fileio")
  69.     openFile(myfile_pclick, "polhemus/click.txt", 0)
  70.     pclick = readFile(myfile_pclick)
  71.     
  72.     put pclick into field "clickdisplay"
  73.     
  74.   end if
  75.   
  76.   the floatPrecision = 2
  77.   
  78.   vX = float(vX)
  79.   vY = float(vY)
  80.   vZ = float(vZ)
  81.   
  82.   --change the polhemus data from model units to pixels
  83.   --our total screen size is 1024 x 768
  84.   --out current model size is 32" x 24"
  85.   
  86.   global vX_adjusted
  87.   global vY_adjusted
  88.   global vZ_adjusted
  89.   
  90.   global modelscale_x
  91.   global modelscale_y
  92.   
  93.   global screenscale_x
  94.   global screenscale_y
  95.   
  96.   modelscale_x = 32.0
  97.   modelscale_y = 24.0
  98.   
  99.   --this is used to adjust the calibration of the wand...how well the position matches the grid
  100.   global calibrationadjust_x
  101.   global calibrationadjust_y
  102.   calibrationadjust_x = the text of field "calibrationadjust_x"
  103.   calibrationadjust_y = the text of field "calibrationadjust_y"
  104.   
  105.   --zero out the calibration if the mouse is being used
  106.   if the mouseH > 0 then 
  107.     calibrationadjust_x = 0.0
  108.     calibrationadjust_y = 0.0
  109.   end if
  110.   
  111.   
  112.   screenscale_x = 1024.0
  113.   screenscale_y = 768.0
  114.   
  115.   the floatPrecision = 2
  116.   
  117.   adjustment_x = float(screenscale_x / (modelscale_x+calibrationadjust_x))
  118.   adjustment_y = float(screenscale_y / (modelscale_y+calibrationadjust_y))
  119.   
  120.   vX_adjusted = vX * adjustment_x
  121.   vY_adjusted = vY * adjustment_y
  122.   
  123.   if vX_adjusted > 1023.0 then 
  124.     --vX_adjusted = 1023.0
  125.   end if
  126.   
  127.   if vY_adjusted > 767.0 then
  128.     --vY_adjusted = 767.0
  129.   end if
  130.   
  131. end
  132.